#include <stdio.h>
#include <string.h>
#include <strings.h>
#include <stdlib.h>
#include <unistd.h>
#include <pthread.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>

int main(int argc, char const *argv[])
{
    if(argc != 3)
    {
        printf("请指定服务器IP和端口\n");
        exit(0);
    }

    int sockfd = socket(AF_INET, SOCK_STREAM, 0);

    struct sockaddr_in peeraddr;
    socklen_t len = sizeof(peeraddr);
    bzero(&peeraddr, len);

    peeraddr.sin_family = AF_INET;
    peeraddr.sin_addr.s_addr = inet_addr(argv[1]);
    peeraddr.sin_port = htons(atoi(argv[2]));

    if(connect(sockfd, (struct sockaddr *)&peeraddr, len) == -1 )
    {
        perror("连接失败");
        exit(0);
    }

    sleep(1);
    send(sockfd, "a", 1, MSG_OOB);

    sleep(1);
    send(sockfd, "123", 3, MSG_OOB);

    // 5，关闭socket
    close(sockfd);
    
    return 0;
}
